// components/operateNav/index.js
let arr = [
  {
    title:'首页',
    icon:'/packageA/images/1.png',
    selected_icon:'/packageA/images/1_selected.png',
    path:'../../operate/index/index'
  },
  {
    title:'开户',
    icon:'/packageA/images/2.png',
    selected_icon:'/packageA/images/2_selected.png',
    path:'../../operate/account/accountlist'
  },
  {
    title:'加盟商',
    icon:'/packageA/images/3.png',
    selected_icon:'/packageA/images/3_selected.png',
    path:'../../operate/joinin/joininlist'
  },
  {
    title:'楼盘',
    icon:'/packageA/images/4.png',
    selected_icon:'/packageA/images/4_selected.png',
    path:'../../operate/floor/floor'
  },
  {
    title:'个人中心',
    icon:'/packageA/images/5.png',
    selected_icon:'/packageA/images/5_selected.png',
    path:'../../operate/account-center/account-center',
    status:true
  },
]

let arr2 = [
  {
    title:'首页',
    icon:'/packageA/images/1.png',
    selected_icon:'/packageA/images/1_selected.png',
    path:'../../operate/index/index'
  },
  {
    title:'楼盘',
    icon:'/packageA/images/4.png',
    selected_icon:'/packageA/images/4_selected.png',
    path:'../../operate/floor/floor'
  },
  {
    title:'个人中心',
    icon:'/packageA/images/5.png',
    selected_icon:'/packageA/images/5_selected.png',
    path:'../../operate/account-center/account-center',
    status:true
  },
]
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    currentIndex:Number
  },
  lifetimes: {
    attached: function() {
      console.log(wx.getStorageSync('role_id'))
      for (let index = 0; index < arr.length; index++) {
        if(index == 1 || index == 2){
          arr[index].status = wx.getStorageSync('role_id') == 22 ? false : true
        }else if(index == 0 && wx.getStorageSync('role_id') == 22){
          arr[index].path = '../../operate/index/secondindex'
        }else{
          arr[index].status = true
        }
        arr[index].num = wx.getStorageSync('role_id')
      }

      for (let index = 0; index < arr2.length; index++) {
        if(index == 1 || index == 2){
          arr2[index].status = wx.getStorageSync('role_id') == 22 ? false : true
        }else if(index == 0 && wx.getStorageSync('role_id') == 22){
          arr2[index].path = '../../operate/index/secondindex'
        }else{
          arr2[index].status = true
        }
        arr2[index].num = wx.getStorageSync('role_id')
      }
      let role_id = wx.getStorageSync('role_id')
      let site = wx.getStorageSync('site')
      if(role_id == 22 ||  role_id == 23 || site == 'demo_site'){
        this.setData({
          list:arr2
        })
      }else{
        this.setData({
          list:arr
        })
      }
      // 在组件实例进入页面节点树时执行
    },
    detached: function() {
      // 在组件实例被从页面节点树移除时执行
    },
  },
  /**
   * 组件的初始数据
   */
  data: {
    list:[
    ]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    handleSelectTab(e){
      this.setData({
        currentIndex:e.currentTarget.dataset.index
      })
    }
  }
})
